<template>
  <div class="columninfom">
    <el-table :data="tableData" style="width: 100% ">
      <el-table-column type="index" label="序号" width="50">
      </el-table-column>
      <el-table-column prop="info" label="模板名称" :show-overflow-tooltip="true" align="center">
      </el-table-column>
      <el-table-column prop="createdDate" label="创建时间" width="200" align="center">
      </el-table-column>
      <el-table-column prop="deletedDate" label="删除时间" width="200" align="center">
      </el-table-column>
      <el-table-column prop="operator" label="删除人员" width="120" align="center">
      </el-table-column>
      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          　　　　　　<el-button type="text" @click="TemplatePreview(scope.row)">浏览</el-button>
          　　　　　　<el-button type="text" @click="TemplateRestore(scope.row)" v-hasPermi="['system:recycle:update']">还原</el-button>
          　　　　　　<el-button type="text" @click="TemplateDelete(scope.row)" v-hasPermi="['system:recycle:remove']">彻底删除</el-button>
          　　　　</template>
      </el-table-column>
    </el-table>


    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
  </div>
</template>
<script>
import {
  getRecycleTemplateInfo,
  restoreTemplate,
  deleteTem,
} from "@/api/content/recyclingStation";
export default {
  props: {
    siteRow: Object,
  },
  data() {
    return {
      tableData: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 0,
      resRestore: [],
      resDelete: [],
      currentPage: 1,
    };
  },

  components: {},

  computed: {},

  mounted() {
    this.getList();
  },

  methods: {
    TemplatePreview(row) {
      let { href } = this.$router.resolve(`/template/view/${row.id}`);
      window.open(href, "_blank");
    },
    //还原回收站模板
    TemplateRestore(row) {
      this.$confirm("此操作将还原该模板, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          restoreTemplate({ templateId: row.id }).then((res) => {
            this.resRestore = res.data;
            if (res.code == 200) {
              this.getList();
            }
          });
          this.msgSuccess("还原成功");
        })
        .catch(() => {
          this.msgSuccess("已取消还原");
        });
    },
    //彻底删除回收站模板
    TemplateDelete(row) {
      this.$confirm("此操作将彻底删除该模板, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteTem({ templateId: row.id }).then((res) => {
            this.resDelete = res.data;
            if (res.code == 200) {
              this.getList();
            }
          });
          this.msgSuccess("删除成功");
        })
        .catch(() => {
          this.msgSuccess("已取消删除");
        });
    },
    //读取回收站模板信息
    getList() {
      let dictType = 1;
      this.queryParams.siteId = this.siteRow?.siteId || 0;
      this.queryParams.dictType =1
      getRecycleTemplateInfo( this.queryParams).then((res) => {
        this.tableData = res.data.list;
        this.total = res.data.totalCount;
      });
    },
  },
};
</script>

<style scoped lang='scss'>
.columninfom {
  height: 100%;
  width: 100%;
  margin: auto;
  .el-table {
    width: 100%;
  }
}
.fontzz {
  font-size: 11pt;
  margin: 0px 230px;
  background-attachment: fixed;
}
</style>